<template>
    <!-- data-fy-img属性不要动，给自定义的v-image-load指令用的  -->
    <div data-fy-img="true">
        <img :src="src" :alt="alt" v-bind="additionalProps" @click="handleClick" />
    </div>
</template>

<script setup>

// 定义props
const props = defineProps({
    src: {
        type: String,
        required: false,
    },
    alt: {
        type: String,
        default: '',
    },
    // 允许传递额外的props给img元素
    additionalProps: {
        type: Object,
        default: () => ({}),
    },
});

// 定义emits
const emit = defineEmits(['click']);

// 处理点击事件
const handleClick = () => {
    emit('click');  
};
</script>

<style lang="scss" scoped>
img {
    display: inline-block;
    width: 100%;
    height: 100%;
}
</style>